<template>
  <el-cascader
    :options="treeData"
    size="mini"
    :props="{label: 'name', value: 'id'}"
    :value="value"
    @change="change"
  />
</template>
<script>
import { reqGetDepts } from '@/api/department'
import { translateToTreeData } from '@/utils'
export default {
  props: {
    value: {
      type: Number,
      default: 0
    }
  },
  data() {
    return {
      treeData: []
    }
  },
  async created() {
    this.treeData = translateToTreeData((await reqGetDepts()).data, 0)
  },
  methods: {
    change(val) {
      console.log(val)
      this.$emit('input', val[val.length - 1])
    }
  }

}
</script>

<style>

</style>
